package com.j256.ormlite.stmt.mapped;

import com.j256.ormlite.field.FieldType;
import com.j256.ormlite.field.SqlType;
import com.j256.ormlite.logger.Log.Level;
import com.j256.ormlite.logger.Logger;
import com.j256.ormlite.stmt.ArgumentHolder;
import com.j256.ormlite.stmt.PreparedDelete;
import com.j256.ormlite.stmt.PreparedQuery;
import com.j256.ormlite.stmt.PreparedUpdate;
import com.j256.ormlite.stmt.StatementBuilder.StatementType;
import com.j256.ormlite.support.CompiledStatement;
import com.j256.ormlite.support.DatabaseConnection;
import com.j256.ormlite.table.TableInfo;
import java.sql.SQLException;

public class MappedPreparedStmt<T, ID> extends BaseMappedQuery<T, ID>
  implements PreparedQuery<T>, PreparedDelete<T>, PreparedUpdate<T>
{
  private final ArgumentHolder[] argHolders;
  private final Long limit;
  private final StatementBuilder.StatementType type;

  public MappedPreparedStmt(TableInfo<T, ID> paramTableInfo, String paramString, FieldType[] paramArrayOfFieldType1, FieldType[] paramArrayOfFieldType2, ArgumentHolder[] paramArrayOfArgumentHolder, Long paramLong, StatementBuilder.StatementType paramStatementType)
  {
    super(paramTableInfo, paramString, paramArrayOfFieldType1, paramArrayOfFieldType2);
    this.argHolders = paramArrayOfArgumentHolder;
    this.limit = paramLong;
    this.type = paramStatementType;
  }

  private CompiledStatement assignStatementArguments(CompiledStatement paramCompiledStatement)
    throws SQLException
  {
    while (true)
    {
      try
      {
        if (this.limit != null)
          paramCompiledStatement.setMaxRows(this.limit.intValue());
        boolean bool = logger.isLevelEnabled(Log.Level.TRACE);
        Object[] arrayOfObject = null;
        if (bool)
        {
          int i = this.argHolders.length;
          arrayOfObject = null;
          if (i > 0)
          {
            arrayOfObject = new Object[this.argHolders.length];
            break label214;
            if (j < this.argHolders.length)
            {
              Object localObject2 = this.argHolders[j].getSqlArgValue();
              FieldType localFieldType = this.argFieldTypes[j];
              if (localFieldType == null)
              {
                localSqlType = this.argHolders[j].getSqlType();
                paramCompiledStatement.setObject(j, localObject2, localSqlType);
                if (arrayOfObject == null)
                  break label220;
                arrayOfObject[j] = localObject2;
                break label220;
              }
              SqlType localSqlType = localFieldType.getSqlType();
              continue;
            }
            logger.debug("prepared statement '{}' with {} args", this.statement, Integer.valueOf(this.argHolders.length));
            if (arrayOfObject != null)
              logger.trace("prepared statement arguments: {}", arrayOfObject);
            if (1 == 0)
              paramCompiledStatement.close();
            return paramCompiledStatement;
          }
        }
      }
      finally
      {
        if (0 == 0)
          paramCompiledStatement.close();
      }
      label214: int j = 0;
      continue;
      label220: j++;
    }
  }

  public CompiledStatement compile(DatabaseConnection paramDatabaseConnection, StatementBuilder.StatementType paramStatementType)
    throws SQLException
  {
    return compile(paramDatabaseConnection, paramStatementType, -1);
  }

  public CompiledStatement compile(DatabaseConnection paramDatabaseConnection, StatementBuilder.StatementType paramStatementType, int paramInt)
    throws SQLException
  {
    if (this.type != paramStatementType)
      throw new SQLException("Could not compile this " + this.type + " statement since the caller is expecting a " + paramStatementType + " statement.  Check your QueryBuilder methods.");
    return assignStatementArguments(paramDatabaseConnection.compileStatement(this.statement, paramStatementType, this.argFieldTypes, paramInt));
  }

  public String getStatement()
  {
    return this.statement;
  }

  public StatementBuilder.StatementType getType()
  {
    return this.type;
  }

  public void setArgumentHolderValue(int paramInt, Object paramObject)
    throws SQLException
  {
    if (paramInt < 0)
      throw new SQLException("argument holder index " + paramInt + " must be >= 0");
    if (this.argHolders.length <= paramInt)
      throw new SQLException("argument holder index " + paramInt + " is not valid, only " + this.argHolders.length + " in statement (index starts at 0)");
    this.argHolders[paramInt].setValue(paramObject);
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.j256.ormlite.stmt.mapped.MappedPreparedStmt
 * JD-Core Version:    0.6.2
 */